package com.xjoyt.pay.gateway.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xjoyt.pay.dto.AccessParam;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.gateway.annotations.RestApi;
import com.xjoyt.pay.gateway.constants.RestApiConstant;
import com.xjoyt.pay.gateway.interfaces.CashContract;
import com.xjoyt.pay.gateway.params.CashParam;
import com.xjoyt.pay.master.po.Cash;

@RestController
@RequestMapping("cash")
public class CashController extends GatewayAbstractController
        implements CashContract {

    @Autowired
    private com.xjoyt.pay.master.interfaces.CashContract contract;

    @RestApi(value = RestApiConstant.CASH_BY_MERCHANT, name = "商户提现")
    @Override
    public ExecuteResult<Cash> create(
            @RequestBody(required = false) AccessParam<CashParam> param) {
        param.param.merchantId = getMerchant(param.accessToken).id;
        return contract.create(param.param);
    }

}
